package aod.android.com.bernay.loginandregister;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import aod.android.com.bernay.R;
import aod.android.com.bernay.base.BernayBaseActivity;
import chen.lion.hilib.util.LogUtils;
import chen.lion.hilib.view.bind.HiView;
import cn.jpush.android.api.JPushInterface;

public class BootPageActivity extends BernayBaseActivity implements View.OnClickListener {
    @HiView(R.id.login_tv)
    TextView login_tv;
    @HiView(R.id.register_tv)
    TextView register_tv;

    private static final int PERMISSION_REQUEST_COARSE_LOCATION = 1;

    @Override
    protected int initLayout() {
        return R.layout.activity_bootpage;
    }

    @Override
    protected void initData() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            // Android M Permission check
            requestPermissions(new String[]{Manifest.permission.CAMERA,Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.ACCESS_WIFI_STATE,Manifest.permission.RECORD_AUDIO,Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_COARSE_LOCATION);

        }
        login_tv.setOnClickListener(this);
        register_tv.setOnClickListener(this);

        LogUtils.e("id="+JPushInterface.getRegistrationID(this));
    }
    @Override
    public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults) {
        switch (requestCode) {
            case PERMISSION_REQUEST_COARSE_LOCATION:
                if (grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                    // TODO request success
                }
                break;
        }

    }
    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.login_tv :
                goActivity(LoginActivity.class);
                finish();
                break;
            case R.id.register_tv :
                Bundle bundle =  new Bundle();
                bundle.putString("register","1");//1为注册 2为忘记密码
                goActivity(RegisterAndForgetPwdActivity.class,bundle);
                finish();
                break;
        }

    }
}
